home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7902 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Pointer arithmetic
  5. Date: Thu, 29 Feb 96 13:07:14 GMT
  6. Organization: none
  7. Message-ID: <825599234snz@genesis.demon.co.uk>
  8. References: <4h2r55$er@s3.iway.fr>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4h2r55$er@s3.iway.fr> assetsto@pratique.fr "Pascal Terracol" writes:
  15.  
  16. > Hello,
  17. >
  18. >this sample code have been correctly working on a pc 80286 processor
  19. >
  20. >I put it on a mac and the pointers seems to act differently...
  21.  
  22. "Differently" doesn't tell us very much. What were you expecting it to do?
  23. What did it actually do?
  24.  
  25. I've had to reformat your code to make any sense of it.
  26.  
  27. >         int size, n1, n2 ;
  28. >         Point  *p_debut, *p1, *p2 ; /* "vecteur" de translation des adr  */
  29. >
  30. >...
  31. >
  32. >      n1 = (int) (l->p1)/sizeof(Point) ;
  33.  
  34. What is l, in particular what is the p1 member? Why are you dividing by
  35. sizeof(Point)?
  36.  
  37. >      n2 = (int) (l->p2)/sizeof(Point) ;
  38.  
  39. Similarly.
  40.  
  41. >      p1 = p_debut + n1 ;
  42. >      p2 = p_debut + n1 ;
  43.  
  44. Did you want p1 and p2 to be assigned the same value? Since the pointers here
  45. aren't used there is no way of telling how they 'act'.
  46.  
  47. >...
  48. >
  49. >is there a cast solution ?
  50.  
  51. Casts are not a magic cure - they often create more problems than they
  52. solve.
  53.  
  54. >this is the "Point" structure 
  55. >
  56. >typedef struct  {   float x, y, z ;      /*   coordonnes point 3d        */
  57. >                    float tx, ty, tz ;   /*   coord. transformee 3d      */
  58. >                    float px, py, pz ;   /*   coord. pixels fenetre2d    */
  59. >                    int ix, iy  ;        /*   coord. pixels 2d ecran     */
  60. >                    int   compute ;      /*   point calcule ? 1 oui      */
  61. >                }   Point ;
  62.  
  63. -- 
  64. -----------------------------------------
  65. Lawrence Kirby | fred@genesis.demon.co.uk
  66. Wilts, England | 70734.126@compuserve.com
  67. -----------------------------------------
  68.